<script lang="ts" setup>
import { useUserStore } from "@/stores/user";
import { ref, onMounted } from "vue";

const { getUserInfo, logout } = useUserStore();
const name = ref<string>("");

onMounted(() => {
  const user = getUserInfo;
  name.value = user?.name || "匿名";
});
</script>

<template>
  <el-dropdown>
    <div class="user-label">
      {{ name }}
    </div>
    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item>切换角色</el-dropdown-item>
        <el-dropdown-item>修改密码</el-dropdown-item>
        <el-dropdown-item divided @click="logout(true)">注销</el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>

<style lang="scss" scoped>
.user-label {
  cursor: pointer;
  outline: none;
  color: white;
}
</style>
